import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description: leetcode 简单练习题：错误的集合
 */
class Solution {
    public int[] findErrorNums(int[] nums) {
        Arrays.sort(nums);
        int[] num = new int[2];
        int sum1 = (1 + nums.length) * nums.length / 2;
        int sum2 = 0;
        for(int i = 0; i < nums.length - 1; i++){
            if(nums[i] == nums[i + 1]){
                num[0] = nums[i];
            }else{
                sum2 += nums[i];
            }
        }
        sum2 += nums[nums.length - 1];
        num[1] = sum1 - sum2;
        return num;
    }
}


public class Tset {

}
